<?php
/**
 * 添加管理员组页面
 * User: lvshuyun
 * Date: 2015/6/9
 * Time: 10:28
 */
use yii\helpers\Url;
use common\widgets\Box;
use common\widgets\ActiveForm;
use common\widgets\ButtonGroup;

$this->title = '管理员管理';


$form = ActiveForm::begin();
echo $form->field($model, 'roleName')->textInput();

?>
<div class="form-group">
<label class="control-label col-sm-3" for="adminrole-power">权限</label>
<div class="col-sm-6">
    <?php
    foreach($allPowers as $module){
        ?>
        <dl>
            <dt><h4><b><?php echo $module['title'];?></b></h4></dt>
            <dd>
                <?php
                foreach($module['child'] as $k => $p){
                    if(isset($p[4]) && is_array($p[4])){
                        ?>
                        <dl>
                            <dt>
                                <?php
                                if(in_array($p[0].'/'.$p[1], $powers)){
                                    $chk = "<input checked name='none' type='checkbox' value='".$p[0].'/'.$p[1]."'/>".$p[2];
                                }else{
                                    $chk = "<input name='none' type='checkbox' value='".$p[0].'/'.$p[1]."'/>".$p[2];
                                }
                                echo $chk . '&nbsp;&nbsp;';
                                ?>
                            </dt>
                            <dd>
                                <?php
                                foreach($p[4] as $v){
                                    if(in_array($v[0].'/'.$v[1], $powers)){
                                        $chk = "<input checked name='power[]' type='checkbox' value='".$v[0].'/'.$v[1]."'/>".$v[2];
                                    }else{
                                        $chk = "<input name='power[]' type='checkbox' value='".$v[0].'/'.$v[1]."'/>".$v[2];
                                    }
                                    echo $chk . '&nbsp;&nbsp;';
                                }
                                ?>
                            </dd>
                        </dl>
                <?php
                    }else{
                        if(in_array($p[0].'/'.$p[1], $powers)){
                            $chk = "<input checked name='power[]' type='checkbox' value='".$p[0].'/'.$p[1]."'/>".$p[2];
                        }else{
                            $chk = "<input name='power[]' type='checkbox' value='".$p[0].'/'.$p[1]."'/>".$p[2];
                        }
                        if($k>0 && $p[0] != $module['child'][$k-1][0]){
                            echo "</dd><dd>" . $chk;
                        }else{
                            if($k>0) echo '&nbsp;&nbsp;';
                            echo $chk;
                        }
                    }
                }
                ?>
            </dd>
        </dl>
    <?php
    }
    ?>
</div>

</div>
<?php
ActiveForm::end();

